home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Atari Mega Archive 1
/
Atari Mega Archive - Volume 1.iso
/
graphics
/
mandlbx1.arc
/
WINDOW.C
< prev
Wrap
C/C++ Source or Header
|
1985-11-20
|
17KB
|
600 lines
/* window.c
* Main loop manages GEM windows, AES, mouse, menues, and drawing process.
*/
#include <obdefs.h>
#include <define.h>
#include <gemdefs.h>
#include <vdibind.h>
#include <osbind.h>
#include <stdio.h>
#include <debug.h>
#include "\t\mandlbox.h"
/*#define WI_KIND (SIZER|MOVER|FULLER| CLOSER|NAME|VSLIDE)*/
#define WI_KIND (CLOSER|NAME|VSLIDE)
#define MIN_WIDTH (2*gl_wbox)
#define MIN_HEIGHT (3*gl_hbox)
int gl_hchar, gl_wchar, gl_wbox, gl_hbox; /* system sizes */
int ps_handle; /* physical screen (workstation) handle */
int vs_handle; /* virtual screen (workstation) handle */
int wi_handle; /* window handle */
int old_res; /* initial resolution of screen */
int xdesk,ydesk,hdesk,wdesk; /* size of whole desktop */
int xwork,ywork,hwork,wwork; /* size of current working window */
int xold,yold,hold,wold; /* size of screen before FULL cmd */
int msgbuff[8]; /* event message buffer */
int keycode; /* keycode returned by event-keyboard */
int mx,my; /* mouse x and y pos. */
int butdown; /* button state tested for, UP/DOWN */
int ret; /* dummy return variable */
int clut_rotate; /* mode */
/******* shared memory with draw.c: */
double Vx0, Vy0, Vxw, Vyw; /* Size of viewed area, in real numbers */
int Niter; /* max number of iterations */
int box_invisible;
/******* shared memory with stitch.c: */
int no_check = 1;
int contrl[12], intin[128], ptsin[128], intout[128];
int ptsout[128]; /* storage wasted for idiotic bindings */
char str[128];
GRECT work_clip;
int draw_state;
char *p_menu;
#define c(x) 1000*(2*(x)+1)/16
int desks_clut[16][3], mandel_clut[16][3] =
{ {c(7),c(7),c(7)}, /* white */
{c(0),c(0),c(0)}, /* black */
{c(7),c(1),c(1)}, /* red */
{c(7),c(4),c(0)},
{c(7),c(6),c(0)},
{c(7),c(7),c(0)}, /* yellow */
{c(6),c(7),c(0)},
{c(0),c(7),c(0)}, /* green */
{c(0),c(7),c(5)},
{c(0),c(7),c(6)}, /* blue */
{c(0),c(6),c(7)},
{c(2),c(3),c(7)},
{c(4),c(0),c(7)},
{c(6),c(0),c(7)}, /* violet */
{c(7),c(0),c(6)},
{c(7),c(0),c(4)}
};
struct places
{ double x, y, dx, dy;
int menue_number;
int iter_ct;
char name[20];
} places[] =
{{.651350,-.176159, .000929, .000636, MGOLUM, 1024, "Golum"},
{.166765,-.807549, .018935, .012964, MRIPPLE, 1024, "Ripple"},
{.054566,-.755330, .002208, .001512, MPINWH, 1024, "Pinwheels"},
{.127512,-.781265, .011749, .008044, MSWIRLS, 1024, "Swirls"},
{.656728,-.174796, .004559, .003122, M3ON4, 1024, "3 on 4"},
{.650663,-.176422, .001890, .001249, MTURTLE, 1024, "Turtle"},
{-1.0, -1.85, 2.0, 2.4, MBUDDAH, 256, "Buddah"}};
struct
{ char active, on_crt;
int hidden;
int want_active;
char new0, new1;
int x0,y0, x1,y1;
int xyarray[10];
} rbox = {0, 1, FALSE, 0};
char *fs_get();
main()
{ int event, mouse_buttons, mmoving, fulled;
int x0, y0, xw, yw, i, j;
int *p_val;
/* if ((old_res=Getrez()) != 0) /* won't work with AES */
/* Setscreen(-1, -1, 0); /* make low resolution */
appl_init();
open_vwork();
open_window();
open_rsc();
Niter = 256; /* inz count till black */
inz_dialog();
graf_mouse(ARROW,0x0L);
fulled=FALSE;
butdown=TRUE;
box_invisible = 1;
dr_iRastWindow(xwork, ywork, wwork, hwork);
dr_iProgCoords(-1.0,-1.85, 2.0,2.4);
dr_Vreset();
do
{ if (draw_state==0 || mmoving)
{ event = evnt_multi(
MU_MESAG| MU_BUTTON| MU_KEYBD | MU_TIMER,
1,1,butdown,
0,0,0,0,0, 0,0,0,0,0,
msgbuff,100,0, /* 100 ms timer*/
&mx,&my,&mouse_buttons,&ret,&keycode,&ret);
}else
{ event = evnt_multi(MU_MESAG| MU_BUTTON| MU_KEYBD| MU_M1,
1,1,butdown,
1,0,0,0,0, /* (always true event) */
0,0,0,0,0, msgbuff,0,0,
&mx,&my,&mouse_buttons,&ret,&keycode,&ret);
}
if (event & MU_MESAG) switch (msgbuff[0])
{ case WM_REDRAW: /* set clip and draw_mode */
start_redraw(1, msgbuff[4],msgbuff[5],msgbuff[6],
msgbuff[7]); /*!!!*/
break;
case WM_NEWTOP: /* unsure of what this does, so boobytrap*/
case WM_TOPPED:
wind_set(wi_handle,WF_TOP,0,0,0,0);
break;
case WM_SIZED:
case WM_MOVED:
if (msgbuff[6]<MIN_WIDTH) msgbuff[6] = MIN_WIDTH;
if (msgbuff[7]<MIN_HEIGHT) msgbuff[7] = MIN_HEIGHT;
wind_set(wi_handle,WF_CURRXYWH,
msgbuff[4],msgbuff[5],msgbuff[6],msgbuff[7]);
wind_get(wi_handle,WF_WORKXYWH,&xwork,&ywork,&wwork,&hwork);
dr_iRastWind(xwork,ywork, wwork,hwork);
start_redraw(-1, xwork, ywork, wwork, hwork);
break;
case WM_FULLED:
if(fulled == 0) /* to full: */
{ wind_calc(WC_BORDER,WI_KIND,xwork,ywork,wwork,
hwork, &xold,&yold,&wold,&hold);
wind_calc(WC_WORK,WI_KIND,xdesk,ydesk,wdesk,
hdesk,&xwork,&ywork,&wwork,&hwork);
wind_set(wi_handle,WF_CURRXYWH,xdesk,ydesk,
wdesk,hdesk);
}else /* to un-full: */
{ wind_calc(WC_WORK,WI_KIND,xold,yold,wold,hold,
&xwork,&ywork,&wwork,&hwork);
wind_set(wi_handle,WF_CURRXYWH,xold,yold,
wold,hold);
}
fulled ^= TRUE;
dr_iRasterWindow(xwork, ywork, wwork, hwork);
start_redraw(-1, xwork, ywork, wwork, hwork);
break;
case MN_SELECTED:
switch (msgbuff[4])
{
case MSAVEAS:
write_scr(fs_get("man"));
break;
case MOPEN:
read_scr(fs_get("man"));
draw_state = 0;
break;
case MCROTATE:
clut_rotate = 1-clut_rotate;
break;
case MQUIT:
goto quit;
case MBUDDAH: case MRIPPLE: case MPINWH:
case MSWIRLS: case M3ON4: case MTURTLE:
case MGOLUM:
for (i=0;places[i].menue_number!=msgbuff[4];i++)
if(places[i].menue_number ==0) break;
dr_iProgCoords(places[i].x, places[i].y,
places[i].dx, places[i].dy);
start_redraw(1, xwork, ywork, wwork, hwork);
dr_Vreset();
Niter = places[i].iter_ct;
break;
case MZOUT4:
dr_zoom(xwork-wwork*3/2, ywork-hwork*3/2,
xwork+wwork*5/2, ywork+hwork*5/2);
start_redraw(1, -1, 0, 0, 0);
break;
case MZNUMBER:
zoom_numerically();
break;
case MQPAINT: /* patch-up area */
printf("\nmqpaint\n");
while (1 + (mouse_buttons & 3))
{ fprintf(stderr,"*******");
dr_area(mx, my, 3);
dr_putBuf( 7*7 );
fprintf(stderr,"!!!!!!!!\n");
event = evnt_multi(MU_MESAG| MU_BUTTON|
MU_KEYBD| MU_M1,
1,1,butdown,
1,0,0,0,0, /* always true */
0,0,0,0,0, msgbuff,0,0,
&mx,&my,&mouse_buttons,&ret,
&keycode,&ret);
}
case ABOUTMAN:
disp_dialog(AUTHOR, 0);
break;
case MUNZOOM:
if (dr_Vpop())
start_redraw(1, -1,0,0,0,0);
break;
case CBOXES:
box_invisible = 1-box_invisible;
break;
case MAITER:
set_iteration();
break;
case MSAVENXT:
case MPLAYMOV:
case MZHELP:
case MZROTATE:
case MAZ2:
default:
form_alert(0,"[1][Detour:|Function Under \
Construction!|Try again next Rev.|(Remember, it's Freeware)][Acknowlege]");
break;
}
menu_tnormal(p_menu, msgbuff[3], TRUE);
break;
}
if (event & MU_KEYBD)
{ keycode &= 0xff;
switch (keycode)
{ case 'D': debug_print = 1-debug_print; break;
case 'C': no_check = 1-no_check; break;
} }
if ((event & MU_BUTTON) /*&&(wi_handle == top_window) ???*/)
butdown ^= 1;
if (draw_state == 0) mouse_buttons = butdown ^ 1;
if (mouse_moving(mx, my, mouse_buttons))
mmoving = 10;
if (mmoving)
{ draw_on_screen(); /* make boxes visible */
view_screen();
mmoving--;
}else
more_redraw();
if (clut_rotate)
rotate_clut(vs_handle,mandel_clut);
} while(!((event & MU_MESAG) && (msgbuff[0] == WM_CLOSED)));
quit:
menu_bar(p_menu, FALSE);
load_clut(vs_handle, desks_clut, (long)0);
wind_close(wi_handle);
graf_shrinkbox(xwork+wwork/2,ywork+hwork/2,gl_wbox,gl_hbox,xwork,ywork,wwork,hwork);
wind_delete(wi_handle);
v_clsvwk(vs_handle);
appl_exit();
/* if (old_res != 0) /*won't work with AES
/* Setscreen(-1, -1, old_res); /* restore resolution */
}
zoom_numerical